

$(function () {

});

//绑定控件
var bind = function () {

    try {

    }
    catch (e) {
        alert(e);
    }
}

//查询模板
var search = function () {
    try {
        let vLoginName = document.getElementById("txt_LoginName").value;
        let vPassWord = document.getElementById("txt_PassWord").value;
        let vValidateCode = document.getElementById("txt_ValidateCode").value;

        if (String(vLoginName).trim() == "") {
            alert("请输入用户名!");
            return;
        }

        if (String(vPassWord).trim() == "") {
            alert("请输入密码!");
            return;
        }

        if (String(vValidateCode).trim() == "") {
            alert("请输入验证码!");
            return;
        }

        if (judgeValidateCode(vValidateCode) == false) {
            alert("验证码输入错误!");
            return;
        }

        var vXheList = new XheList();
        vXheList.model.Table = "t_sys_user";
        vXheList.model.SortName = "id";
        vXheList.model.Columns = [
            ["id", "用户ID", "10", "null", "I", "", true],
            ["appid", "AppID", "10", "", "C", "", true],
            ["token", "Token", "10", "", "C", "", true],
            ["username", "用户姓名", "10", "", "C", "", true],
            ["keyid", "KeyID", "10", "", "C", "", true],
            ["credcode", "证书信息", "10", "", "C", "", true]
        ];
        vXheList.model.Filter = [
            ["loginname", "A", "EQ", "C", vLoginName],
            ["password", "A", "EQ", "C", vPassWord],
            ["status", "A", "EQ", "I", 1]
        ];

        let vResult = vXheList.query();

        if (vResult.rows != undefined && vResult.rows.length > 0) {

            USER_INFO.UserID = vResult.rows[0].id;
            USER_INFO.AppID = vResult.rows[0].appid;
            USER_INFO.Token = vResult.rows[0].token;
            USER_INFO.UserName = vLoginName;
            USER_INFO.RealName = vResult.rows[0].username;
            USER_INFO.KeyID = vResult.rows[0].keyid;
            USER_INFO.KeyCode = "";
            USER_INFO.DistrictName = "";
            USER_INFO.DistrictCode = "";
            USER_INFO.OrganizeCode = "";
            USER_INFO.OrganizeName = "";
            USER_INFO.CredCode = vResult.rows[0].credcode;
            USER_INFO.UserLimitDate = "";
            USER_INFO.Permission = [
                {
                    id: "1324545153343557632",
                    name: "人社大数据应用",
                    code: "DSJYY",
                    model: [
                        { code: "PEUI", auth: "search|edit|del|apply|approval|export" }
                    ]
                }
            ];
       

            Cookie.setJSONCookie("loginname", vLoginName);
            Cookie.setJSONCookie(vLoginName, USER_INFO);

            window.open("../../view/pages/index.html", "_self");

        }
        else {
            alert("登录失败,请检查用户名及密码是否填写正确!");
        }
    }
    catch (e) {
        alert(e);
    }
}






